package cn.edu.swu.controller;

import cn.edu.swu.service.GrabLessonsService;
import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Classname LoginController
 * @Description TODO
 * @Date 2021/9/5 23:54
 * @Author Lenovo
 * @Modified by
 */
@RestController
public class LoginController {
    @Autowired
    private GrabLessonsService grabLessonsService;

    @PostMapping("/grab")
    public String grab(@RequestParam("u") String username,@RequestParam("p")String password) {


        try {
            grabLessonsService.grab(username, password);
        } catch (Exception e) {
            return JSON.toJSONString("error");
        }
        return JSON.toJSONString("success");
    }
}
